{{Strip}}{{Extend "layout"}}
{{/*Block "bodyNav"}}
{{Include "filemanager/file.dirnav"}}
{{/Block*/}}
{{Block "title"}}{{"附件管理"|$.T}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li>{{"附件管理"|$.T}}</li>
<li class="active">{{"文件管理"|$.T}}: {{/* $.Stored.Get "absPath" */}}
  <a href="{{call $.Func.URLPrefix}}?gallery=1">
    <span class="badge badge-primary">{{$.Stored.rootPath}}</span>
  </a>
  {{- range $k,$v := $.Stored.pathLinks -}}
  /<a href="{{$v.V}}">{{$v.K}}</a>
  {{- end -}}
</li>
{{/Block}}

{{Block "head"}}
{{Include "filemanager/file.head"}}
<link rel="stylesheet" href="{{AssetsURL}}/js/magnific-popup/magnific-popup.min.css?t={{BuildTime}}" type="text/css">
{{/Block}}

{{Block "main"}}
{{- $path := $.Stored.Get "path" -}}
<div class="row">
  <div class="col-md-12">
      <div class="btn-group">
        {{Include "manager/uploaded_file_btn"}}
        {{- if $path -}}
        <a title="{{`点击回到上一级`|$.T}}" class="btn btn-default" href="{{call $.Func.URLPrefix}}?gallery=1&path={{$path}}/.." style="margin-left:10px">
          <i class="fa fa-reply"></i>
          {{"返回上一级"|$.T}}
        </a>
        {{- end -}}
      </div>
    </div>
</div>



<div class="row">
  <div class="col-md-12" id="tbody-content">
    <div class="gallery-cont" style="margin-left:-10px">
      {{- range $k,$v := $.Stored.dirs -}}
      <div class="item">
        <div class="photo">
          <div class="head">
            <!-- <span class="pull-right"> <i class="fa fa-heart"></i> </span> -->
            <h4 data-toggle="tooltip" title="{{$v.Name}}">{{$v.Name}}</h4>
            <span class="desc">{{$v.ModTime.Format "2006-01-02 15:04:05"}}</span>
          </div>
          {{- $fileType := FileTypeByName $v.Name -}}
          {{- if $v.IsDir -}}
          <div class="icon">
          <a href="{{call $.Func.URLPrefix}}?gallery=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}">
            <i class="fa fa-folder"></i>
          </a>
          </div>
          {{- else if eq $fileType `image` -}}
          <div class="img">
            <img src="{{call $.Func.URLPrefix}}?inline=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" />
            <div class="over">
              <div class="func">
                <a href="{{call $.Func.URLPrefix}}?inline=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" target="_blank">
                  <i class="fa fa-link"></i>
                </a>
                <a class="image-zoom" href="{{call $.Func.URLPrefix}}?inline=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" title="{{$v.Name}}">
                  <i class="fa fa-search"></i>
                </a>
              </div>
            </div>
          </div>
          {{- else -}}
          <div class="icon">
          <a href="{{call $.Func.URLPrefix}}?gallery=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}">
            <i class="fa fa-{{FileTypeIcon $fileType}}"></i>
          </a>
          </div>
          {{- end -}}
        </div>
      </div>
      {{- end -}}
    </div>

  </div>
</div>

{{/Block}}

{{Block "footer"}}
<script type="text/javascript" src="{{AssetsURL}}/js/masonry/masonry.min.js?t={{BuildTime}}"></script>
<script type="text/javascript" src="{{AssetsURL}}/js/magnific-popup/jquery.magnific-popup.min.js?t={{BuildTime}}"></script>
{{Include "filemanager/file.script"}}
<script>
  function uploadURL(currentPath) {
    return '{{call $.Func.URLPrefix}}?do=upload&path=' + encodeURIComponent(currentPath);
  }
  function initDropzone(options) {
    $('#multi-upload-dropzone').dropzone($.extend({},options,{
      url: uploadURL('{{$.Stored.path}}'),
      dictDefaultMessage: '{{"可以把文件拖到这里来进行上传哦"|$.T}}'
    }));
    $('#multi-upload-zip-dropzone').dropzone($.extend({},options,{
      url: uploadURL('{{$.Stored.path}}') + '&pipe=unzip',
      dictDefaultMessage: '{{"可以把文件拖到这里来进行上传哦"|$.T}}<p>{{"仅支持上传zip压缩包。成功解压到当前目录后，该压缩包会被自动删除"|$.T}}</p>',
      acceptedFiles: 'application/zip,application/x-zip-compressed'
    }));
  }
$(function () {
  $('#tbody-content').off().on('refresh',function(){
    //Initialize Mansory
    var $container = $('.gallery-cont');
    // initialize
    $container.masonry({
      columnWidth: 0,
      itemSelector: '.item'
    });

    //Resizes gallery items on sidebar collapse
    $("#sidebar-collapse").click(function () {
      $container.masonry();
    });

    //MagnificPopup for images zoom
    $('.image-zoom').magnificPopup({
      type: 'image',
      mainClass: 'mfp-with-zoom', // this class is for CSS animation below
      zoom: {
        enabled: true, // By default it's false, so don't forget to enable it
        duration: 300, // duration of the effect, in milliseconds
        easing: 'ease-in-out', // CSS transition easing function
        opener: function (openerElement) {
          var parent = $(openerElement).parents("div.img");
          return parent;
        }
      },
      gallery: { enabled: true }
    });
    $(window).trigger('resize');
  }).trigger('refresh');
});
</script>
<script type="text/javascript" src="{{AssetsURL}}/js/behaviour/page/file.min.js?t={{BuildTime}}"></script>
{{/Block}}
{{/Strip}}